<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAppleTasksTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('apple_tasks', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title')->nullable();
            $table->string('app_id')->unique();
            $table->integer('device_type')->index()->default(1);
            $table->integer('type')->index()->default(1);
            $table->integer('thread')->index()->default(1);
            $table->integer('max_running_device_amount')->index()->default(1)->comment('最大同时运行设备数');
            $table->integer('current_running_device_amount')->index()->default(1)->comment('目前同时运行设备数');
            $table->integer('max_account_amount_of_per_deal')->index()->default(1)->comment('单次请求最大账户数');
            $table->integer('target_account_amount')->default(0);
            $table->integer('valid_account_amount')->default(0);
            $table->integer('failed_account_amount')->default(0);
            $table->integer('max_success_amount_of_one_minute')->default(999)->comment('最大完成数/每分钟');
            $table->integer('current_success_amount_of_one_minute')->default(0)->comment('最近一分钟完成数');
            $table->string('app_key')->nullable();
            $table->string('review_name')->default('')->index();
            $table->float('review_rating')->nullable();
            $table->string('rate_id')->nullable();
            $table->float('rate_vote')->nullable();
            $table->text('unknown')->nullable();
            $table->integer('status')->index()->default('1');
            $table->integer('enable')->index()->default('1');
            $table->integer('user_id')->index();
            $table->dateTime('begin_at')->default(DB::raw('CURRENT_TIMESTAMP'));;
            $table->dateTime('finished_at')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('apple_tasks');
    }
}
